package com.wang.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wang.exception.BusinessException;
import com.wang.param.ShopQueryParam;
import com.wang.user.model.Dishes;
import com.wang.user.service.DishesService;
import com.wang.user.mapper.DishesMapper;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
* @author bkty0
* @description 针对表【dishes(菜品)】的数据库操作Service实现
* @createDate 2025-04-23 10:39:20
*/
@Service
public class DishesServiceImpl extends ServiceImpl<DishesMapper, Dishes>
    implements DishesService{

    @Override
    public List<Dishes> listByShopId(Long ShopId) {
        LambdaQueryWrapper<Dishes> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Dishes::getShopId, ShopId);
        return list(queryWrapper);
    }

    @Override
    public Boolean add(Dishes dishes) {
        return save(dishes);
    }

    @Override
    public Boolean deleteById(Long id) {
        Dishes byId = getById(id);
        if (byId != null) {
            throw new BusinessException("菜品信息不存在");
        }
        return removeById(id);
    }
}




